package com.jeomo.shiro.dto;

import com.jeomo.shiro.enums.PlatformEnum;
import com.jeomo.sys.api.bo.UserBo;

import java.io.Serializable;
import java.util.Date;

/**
 * @author QBT
 */
public class LoginInfo implements Serializable {

    /**
     * 登录用户
     */
    private UserBo loginUser;


    /**
     * 登录的平台
     */
    private PlatformEnum loginPlatform;

    /**
     * 当前组织
     */
    private String currentOrgCode;

    /**
     * 当前顶级组织
     */
    private String currentTopOrgCode;


    /**
     * 登录时间
     */
    private Date loginTime;

    /**
     * 登录的token
     */
    private String sessionId;

    /**
     * shiro需要一个这样的key 来区分用户
     * @return
     */
    public String getAuthCacheKey() {
        return getLoginUser().getCode();
    }

// ****************getter setter方法*****************

    public PlatformEnum getLoginPlatform() {
        return loginPlatform;
    }

    public UserBo getLoginUser() {
        return loginUser;
    }

    public void setLoginUser(UserBo loginUser) {
        this.loginUser = loginUser;
    }

    public void setLoginPlatform(PlatformEnum loginPlatform) {
        this.loginPlatform = loginPlatform;
    }

    public String getUsername() {
        return getLoginUser().getUsername();
    }
    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }

    public String getToken() {
        return sessionId;
    }

    public void setToken(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getOrgCode() {
        return getLoginUser().getOrgCode();
    }

    public String getTopOrgCode() {
        return getLoginUser().getTopOrgCode();
    }

    public String getCurrentOrgCode() {
        return currentOrgCode;
    }

    public void setCurrentOrgCode(String currentOrgCode) {
        this.currentOrgCode = currentOrgCode;
    }

    public String getCurrentTopOrgCode() {
        return currentTopOrgCode;
    }

    public void setCurrentTopOrgCode(String currentTopOrgCode) {
        this.currentTopOrgCode = currentTopOrgCode;
    }
}
